  
* ************************************************** *;
* ************************************************** *;
* ************************************************** *;
* "Where Do Third-Parties Intervene? Third-Parties   *; 
* Institutions and Military Interventions in Civil   *; 
* Conflicts" (ISQ forthcoming)                       *; 
*                                                    *;
* by Jun Koga (Emory University)                     *;                                               
* jkoga@emory.edu                                    *;
* January 2011                                       *;
* ************************************************** *;
* ************************************************** *;
* ************************************************** *;

set memory 400m 


* ****************************************************** *;
* ****************************************************** *;
* ****************************************************** *;
* ****************************************************** *;
* Table Results                                           *;
* ****************************************************** *;
* ****************************************************** *;
* ****************************************************** *;
* ****************************************************** *;


#delimit; 
use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\FYP_data_May2010_v1.dta", clear; 
xtset id year;


#delimit;
 mlogit  typeint third_polity  reb_relstr inter5_13    lratio ally lndistance colhist Coldwar 
 premilint con_polity  spellmili  _spline*  ,  robust cluster(id) nolog;


#delimit; 
 mlogit  typeint third_W  reb_relstr inter5_14  lratio ally lndistance colhist Coldwar 
  premilint con_polity third_polity spellmili  _spline* , robust cluster(id) nolog;


#delimit;

mlogit  typeint third_polity  reb_relstr DomDom inter2_11 DomMar inter2_13 
   lratio ally lndistance colhist Coldwar premilint con_polity spellmili _spline* ,robust cluster(id) nolog;


#delimit;

mlogit  typeint third_polity  reb_relstr DomDom inter2_11 
   lratio ally lndistance colhist Coldwar premilint con_polity spellmili _spline* ,robust cluster(id) nolog;


#delimit;
 mlogit  typeint third_W  reb_relstr inter5_14 DomDom inter2_12 DomMar inter2_14 
 lratio ally lndistance colhist Coldwar premilint  con_polity third_polity
spellmili  _spline*   , robust cluster(id) nolog;


#delimit; 
 probit  mili_intervention  third_polity 
SDIAD inter3_3 ethltie inter2_19 lratio ally lndistance colhist Coldwar     
premilint spellmili spellmili2 spellmili3 , robust cluster(id) nolog;

#delimit; 

probit  mili_intervention  third_W
SDIAD inter3_4 ethltie inter2_20 lratio ally lndistance colhist Coldwar     
premilint third_polity spellmili spellmili2 spellmili3 ,robust cluster(id) nolog;

#delimit;
 probit  mili_intervention  third_polity 
SDIAD inter3_3  PDIAD inter4_3    ethltie inter2_19 lratio ally lndistance colhist Coldwar     
premilint  spellmili spellmili2 spellmili3 ,robust cluster(id) nolog;


#delimit;
 probit  mili_intervention  third_polity 
SDIAD inter3_3  HydrocarbonpCNTR inter4_13  ethltie inter2_19 lratio ally lndistance colhist Coldwar     
premilint  spellmili spellmili2 spellmili3, robust cluster(id) nolog;



#delimit;
probit  mili_intervention  third_W 
SDIAD inter3_4  PDIAD inter4_4    ethltie inter2_20 lratio ally lndistance colhist Coldwar     
premilint third_polity spellmili spellmili2 spellmili3, robust cluster(id) nolog;




#delimit;
probit  mili_intervention  third_W
SDIAD inter3_4  HydrocarbonpCNTR inter4_14  ethltie inter2_20 lratio ally lndistance colhist Coldwar     
premilint  third_polity spellmili spellmili2 spellmili3, robust cluster(id) nolog;





* ************************************************** *;
* ************************************************** *;
* ************************************************** *;
* ************************************************** *;
* Relative rebel strength    for Polity              *;  
* ************************************************** *;
* ************************************************** *;
* ************************************************** *;
* ************************************************** *;

#delimit; 
use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\FYP_data_May2010_v1.dta", clear; 
xtset id year;



estsimp mlogit  typeint third_polity  reb_relstr inter5_13 lratio ally lndistance colhist Coldwar 
 premilint con_polity  spellmili  _spline*  , sims(10000) robust cluster(id) nolog;


postutil clear;
postfile mypost diff_hat1 diff_hat2 diff_lo1 diff_hi1 diff_lo2 diff_hi2 
    using "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", replace;
noisily display "start";

local a= 0;
while `a' <= 20 { ;

scalar h_lratio= -1.058528;
scalar h_drugs=0;
scalar h_strebel=0;
scalar h_lndistance=8.297453 ;
scalar h_reb_relstr=1;
scalar h_ally= 0;
scalar h_distance=4937.091;
scalar h_colhist=0; 
scalar h_Coldwar=1; 
scalar h_premilint=0; 
scalar h_con_polity=7; 
scalar h_war=0; 
scalar h_spellmili=9.207655;
scalar h_spellmili2= 172.6125;
scalar h_spellmili3= 4447.729;
scalar h_spline1= -757.8112; 
scalar h_spline2= -1763.558; 
scalar h_spline3= -2452.633; 
scalar h_constant=1;


    generate x_betahat0 = b1*(`a')
                            + b2*h_reb_relstr
                            + b3*h_reb_relstr*(`a')
                            + b4*h_lratio
                            + b5*h_ally
                            + b6*h_lndistance
                            + b7*h_colhist
                            + b8*h_Coldwar
                            + b9*h_premilint
                            + b10*h_con_polity
                            + b11*h_spellmili  
                            + b12*h_spline1
                            + b13*h_spline2
                            + b14*h_spline3
                            + b15*h_constant;

  

    generate x_betahat1 =  b1*(`a')
                            + b2*(h_reb_relstr +3)
                            + b3*(h_reb_relstr +3)*(`a')
                            + b4*h_lratio
                            + b5*h_ally
                            + b6*h_lndistance
                            + b7*h_colhist
                            + b8*h_Coldwar
                            + b9*h_premilint
                            + b10*h_con_polity
                            + b11*h_spellmili  
                            + b12*h_spline1
                            + b13*h_spline2
                            + b14*h_spline3
                            + b15*h_constant;
 

 generate x_betahat2 =   b16*(`a')
                            + b17*h_reb_relstr
                            + b18*h_reb_relstr*(`a')
                            + b19*h_lratio
                            + b20*h_ally
                            + b21*h_lndistance
                            + b22*h_colhist
                            + b23*h_Coldwar
                            + b24*h_premilint
                            + b25*h_con_polity
                            + b26*h_spellmili  
                            + b27*h_spline1
                            + b28*h_spline2
                            + b29*h_spline3
                            + b30*h_constant;

   
    generate x_betahat3 = b16*(`a')
                            + b17*(h_reb_relstr +3)
                            + b18*(h_reb_relstr +3)*(`a')
                            + b19*h_lratio
                            + b20*h_ally
                            + b21*h_lndistance
                            + b22*h_colhist
                            + b23*h_Coldwar
                            + b24*h_premilint
                            + b25*h_con_polity 
                            + b26*h_spellmili  
                            + b27*h_spline1
                            + b28*h_spline2
                            + b29*h_spline3
                            + b30*h_constant;

                                                  
    gen prob0=exp(x_betahat0)/(exp(x_betahat0)+ exp(x_betahat2)+1);
    gen prob1=exp(x_betahat1)/(exp(x_betahat1)+ exp(x_betahat3)+1);
    gen prob2=exp(x_betahat2)/(exp(x_betahat0)+ exp(x_betahat2)+1);
    gen prob3=exp(x_betahat3)/(exp(x_betahat1)+ exp(x_betahat3)+1);

    gen diff1=prob1-prob0;
    gen diff2=prob3-prob2;
      
    egen probhat0=mean(prob0);
    egen  probhat1=mean(prob1);
    egen probhat2=mean(prob2);
    egen  probhat3=mean(prob3);
   
    egen diffhat1=mean(diff1);
    egen diffhat2=mean(diff2);
 
    _pctile prob0, p(5,95) ;
    scalar lo0 = r(r1);
    scalar hi0 = r(r2);  

   
    _pctile prob1, p(5,95);
     scalar lo1= r(r1);
     scalar hi1= r(r2);  
    

 
    _pctile prob2, p(5,95) ;
     scalar lo2= r(r1);
     scalar hi2= r(r2);  
    

    
    _pctile prob3, p(5,95);
     scalar lo3= r(r1);
     scalar hi3= r(r2);  
    

 
   _pctile diff1, p(5,95);
     scalar diff_lo1= r(r1);
     scalar diff_hi1= r(r2);  
 

    _pctile diff2, p(5,95);
       scalar diff_lo2= r(r1);
       scalar diff_hi2= r(r2);  

 
     scalar diff_hat1=diffhat1;
     scalar diff_hat2=diffhat2;
 

 
    post mypost (diff_hat1) (diff_hat2) (diff_lo1) (diff_hi1) (diff_lo2) (diff_hi2) ;        

    drop x_betahat0 x_betahat1 x_betahat2 x_betahat3 prob0 prob1 prob2 prob3 diff1 diff2 probhat0 probhat1 probhat2 probhat3 diffhat1 diffhat2 ;

 local a=`a'+ 1 ;
    display "." _c;
    } ;

display "";

postclose mypost;
#delimit;
use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", clear;

gen index= _n-1;
gen MV=index;


graph twoway line diff_hat2 MV, clwidth(medium) clcolor(blue) clcolor(black)
        ||   line diff_lo2  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line diff_hi2  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            xlabel(0 5 10 15 20)
            yscale(noline)
            xscale(noline)
            yline(0)
            legend(pos(1) col(1) label(1 "Effect of rebel strength on GOV intervention")
                   label(2 "95% confidence interval") 
                  order(1 2) region(lstyle(none)))
            xtitle(Polity Score, size(4)  )
            ytitle("Effect of Rebel strength", size(4))
            xsca(titlegap(2))
            ysca(titlegap(2))
            scheme(s2mono) graphregion(fcolor(white))
            name(PGovstreb,replace);

#delimit;
graph twoway line diff_hat1  MV, clwidth(medium) clcolor(blue) clcolor(black)
        ||   line diff_lo1  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line diff_hi1  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            
            xlabel(0 5 10 15 20)
            yscale(noline)
            xscale(noline)
            yline(0)
            legend(pos(1) col(1) label(1 "Effect of rebel strength on Rebel intervention") 
                   label(2 "95% confidence interval") 
                  order(1 2) region(lstyle(none)))
            
            xtitle(Polity Score, size(4)  )
            ytitle("Effect of Rebel Strength", size(4))
            xsca(titlegap(2))
            ysca(titlegap(2))
            scheme(s2mono) graphregion(fcolor(white))
            name(PRebelstreb,replace);

*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*                 END                                                   *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;



* ************************************************** *;
* ************************************************** *;
* ************************************************** *;
* Relative rebel strength for Winning Coalition      *;  
* ************************************************** *;
* ************************************************** *;
* ************************************************** *;

#delimit; 
use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\FYP_data_May2010_v1.dta", clear; 
xtset id year;

estsimp mlogit  typeint third_W  reb_relstr inter5_14 lratio ally lndistance colhist Coldwar 
  premilint con_polity third_polity spellmili  _spline* , sims(10000) robust cluster(id) nolog;


postutil clear;
postfile mypost diff_hat1 diff_hat2 diff_lo1 diff_hi1 diff_lo2 diff_hi2 
    using "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", replace;
noisily display "start";

local a= 0;
while `a' <= 1 { ;

scalar h_lratio= -1.058528;
scalar h_drugs=0;
scalar h_strebel=0;
scalar h_third_polity=8; 
scalar h_con_polity=7; 
scalar h_reb_relstr=1;
scalar h_ally= 0;
scalar h_xconst2=3; 
scalar h_lndistance= 8.297453 ;
scalar h_colhist=0; 
scalar h_Coldwar=1; 
scalar h_premilint=0; 
scalar h_conf_W=.5; 
scalar h_war=0; 
scalar h_spellmili=9.207655;
scalar h_spellmili2= 172.6125;
scalar h_spellmili3= 4447.729;
scalar h_spline1= -757.8112; 
scalar h_spline2= -1763.558; 
scalar h_spline3= -2452.633; 
scalar h_constant=1;


    generate x_betahat0 = b1*(`a')
                            + b2*h_reb_relstr
                            + b3*h_reb_relstr*(`a')
                            + b4*h_lratio
                            + b5*h_ally
                            + b6*h_lndistance
                            + b7*h_colhist 
                            + b8*h_Coldwar
                            + b9*h_premilint 
                            + b10*h_con_polity
                            + b11*h_third_polity
                            + b12*h_spellmili  
                            + b13*h_spline1
                            + b14*h_spline2
                            + b15*h_spline3
                            + b16*h_constant;

 


    generate x_betahat1 = b1*(`a')
                            + b2*(h_reb_relstr +3)
                            + b3*(h_reb_relstr +3)*(`a')
                            + b4*h_lratio
                            + b5*h_ally
                            + b6*h_lndistance
                            + b7*h_colhist 
                            + b8*h_Coldwar
                            + b9*h_premilint 
                            + b10*h_con_polity
                            + b11*h_third_polity
                            + b12*h_spellmili  
                            + b13*h_spline1
                            + b14*h_spline2
                            + b15*h_spline3
                            + b16*h_constant;


 generate x_betahat2 =  b17*(`a')
                            + b18*h_reb_relstr
                            + b19*h_reb_relstr*(`a')
                            + b20*h_lratio
                            + b21*h_ally
                            + b22*h_lndistance
                            + b23*h_colhist 
                            + b24*h_Coldwar
                            + b25*h_premilint 
                            + b26*h_con_polity
                            + b27*h_third_polity
                            + b28*h_spellmili  
                            + b29*h_spline1
                            + b30*h_spline2
                            + b31*h_spline3
                            + b32*h_constant;
           

    generate x_betahat3 =  b17*(`a')
                            + b18*(h_reb_relstr +3)
                            + b19*(h_reb_relstr +3)*(`a')
                            + b20*h_lratio
                            + b21*h_ally
                            + b22*h_lndistance
                            + b23*h_colhist 
                            + b24*h_Coldwar
                            + b25*h_premilint 
                            + b26*h_con_polity
                            + b27*h_third_polity
                            + b28*h_spellmili  
                            + b29*h_spline1
                            + b30*h_spline2
                            + b31*h_spline3
                            + b32*h_constant;



                                                  
    gen prob0=exp(x_betahat0)/(exp(x_betahat0)+ exp(x_betahat2)+1);
    gen prob1=exp(x_betahat1)/(exp(x_betahat1)+ exp(x_betahat3)+1);
    gen prob2=exp(x_betahat2)/(exp(x_betahat0)+ exp(x_betahat2)+1);
    gen prob3=exp(x_betahat3)/(exp(x_betahat1)+ exp(x_betahat3)+1);

    gen diff1=prob1-prob0;
    gen diff2=prob3-prob2;
      
    egen probhat0=mean(prob0);
    egen  probhat1=mean(prob1);
    egen probhat2=mean(prob2);
    egen  probhat3=mean(prob3);
   
    egen diffhat1=mean(diff1);
    egen diffhat2=mean(diff2);
 
    _pctile prob0, p(2.5,97.5) ;
    scalar lo0 = r(r1);
    scalar hi0 = r(r2);  

    
    _pctile prob1, p(2.5,97.5);
     scalar lo1= r(r1);
     scalar hi1= r(r2);  
     
    _pctile prob2, p(2.5,97.5) ;
     scalar lo2= r(r1);
     scalar hi2= r(r2);  
    
    _pctile prob3, p(2.5,97.5);
     scalar lo3= r(r1);
     scalar hi3= r(r2);  
    
   _pctile diff1, p(2.5,97.5);
     scalar diff_lo1= r(r1);
     scalar diff_hi1= r(r2);  
 

    _pctile diff2, p(2.5,97.5);
       scalar diff_lo2= r(r1);
       scalar diff_hi2= r(r2);  

 
     scalar diff_hat1=diffhat1;
     scalar diff_hat2=diffhat2;
 

 
    post mypost (diff_hat1) (diff_hat2) (diff_lo1) (diff_hi1) (diff_lo2) (diff_hi2) ;        

    drop x_betahat0 x_betahat1 x_betahat2 x_betahat3 prob0 prob1 prob2 prob3 diff1 diff2 probhat0 probhat1 probhat2 probhat3 diffhat1 diffhat2 ;

 local a=`a'+ .05 ;
    display "." _c;
    } ;

display "";

postclose mypost;
#delimit;
use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", clear;

gen index= _n-1;
gen MV= index/20;


graph twoway line diff_hat2 MV, clwidth(medium) clcolor(blue) clcolor(black)
        ||   line diff_lo2  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line diff_hi2  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            xlabel(0 .25 .5 .75  1)
            yscale(noline)
            xscale(noline)
            yline(0)
            legend(pos(1) col(1) label(1 "Effect of rebel strength on Gov intervention") 
                   label(2 "95% confidence interval") 
                  order(1 2) region(lstyle(none)))
            xtitle(Winning Coalition Size, size(4)  )
            ytitle("Effect of Rebel strength", size(4))
            xsca(titlegap(2))
            ysca(titlegap(2))
            scheme(s2mono) graphregion(fcolor(white))
            name(WGovstreb,replace);

#delimit;
graph twoway line diff_hat1  MV, clwidth(medium) clcolor(blue) clcolor(black)
        ||   line diff_lo1  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line diff_hi1  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            
            xlabel(0 .25 .5 .75  1)
            yscale(noline)
            xscale(noline)
            yline(0)
            legend(pos(1) col(1) label(1 "Effect of rebel strength on Rebel intervention") 
                   label(2 "95% confidence interval") 
                  order(1 2) region(lstyle(none)))
            
            xtitle(Winning Coalition Size, size(4)  )
            ytitle("Effect of Rebel Strength", size(4))
            xsca(titlegap(2))
            ysca(titlegap(2))
            scheme(s2mono) graphregion(fcolor(white))
            name(WRebelstreb,replace);


*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*        END                                                            *; 
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;







*  ****************************************************************  *;
*  ****************************************************************  *;
*  ****************************************************************  *;
*    ROBUST CHECK                                                    *; 
*  ****************************************************************  *;
*  ****************************************************************  *;
*  ****************************************************************  *;


******************************************** *;
* ************************************************** *;
* Rebel Finance/Poliy                                *;
* ************************************************** *;
* ************************************************** *;
#delimit; 
use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\FYP_data_May2010_v1.dta", clear; 
xtset id year;

estsimp mlogit  typeint third_polity  drugs inter1_3 lratio ally lndistance colhist Coldwar 
 premilint con_polity spellmili  _spline*, sims(10000) robust cluster(id) nolog;


postutil clear;
postfile mypost diff_hat1 diff_hat2 diff_lo1 diff_hi1 diff_lo2 diff_hi2 
    using "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", replace;
noisily display "start";

local a= 0;
while `a' <=20 { ;

scalar h_lratio= -1.058528;
scalar h_drugs=0;
scalar h_ally= 0;
scalar h_lndistance=8.297453 ;
scalar h_distance=4937.091;
scalar h_colhist=0; 
scalar h_Coldwar=1; 
scalar h_war=0; 
scalar h_con_polity=7; 
scalar h_premilint=0; 
scalar h_spellmili=9.207655;
scalar h_spellmili2= 172.6125;
scalar h_spellmili3= 4447.729;
scalar h_spline1= -757.8112; 
scalar h_spline2= -1763.558; 
scalar h_spline3= -2452.633; 
scalar h_constant=1;


    generate x_betahat0 = b1*(`a')
                            + b2*h_drugs
                            + b3*h_drugs*(`a')
                            + b4*h_lratio
                            + b5*h_ally
                            + b6*h_lndistance
                            + b7*h_colhist
                            + b8*h_Coldwar
                            + b9*h_premilint
                            + b10*h_con_polity
                            + b11*h_spellmili 
                            + b12*h_spline1 
                            + b13*h_spline2
                            + b14*h_spline3
                            + b15*h_constant;

  
    generate x_betahat1 = b1*(`a')
                            + b2*(h_drugs +1)
                            + b3*(h_drugs +1)*(`a')
                            + b4*h_lratio
                            + b5*h_ally
                            + b6*h_lndistance
                            + b7*h_colhist
                            + b8*h_Coldwar
                            + b9*h_premilint
                            + b10*h_con_polity
                            + b11*h_spellmili 
                            + b12*h_spline1 
                            + b13*h_spline2
                            + b14*h_spline3
                            + b15*h_constant;


 generate x_betahat2 =  b16*(`a')
                            + b17*h_drugs
                            + b18*h_drugs*(`a')
                            + b19*h_lratio
                            + b20*h_ally
                            + b21*h_lndistance
                            + b22*h_colhist
                            + b23*h_Coldwar
                            + b24*h_premilint
                            + b25*h_con_polity
                            + b26*h_spellmili 
                            + b27*h_spline1 
                            + b28*h_spline2
                            + b29*h_spline3
                            + b30*h_constant;


    generate x_betahat3 = b16*(`a')
                            + b17*(h_drugs +1)
                            + b18*(h_drugs +1)*(`a')
                            + b19*h_lratio
                            + b20*h_ally
                            + b21*h_lndistance
                            + b22*h_colhist
                            + b23*h_Coldwar
                            + b24*h_premilint
                            + b25*h_con_polity
                            + b26*h_spellmili 
                            + b27*h_spline1 
                            + b28*h_spline2
                            + b29*h_spline3
                            + b30*h_constant;
            
    gen prob0=exp(x_betahat0)/(exp(x_betahat0)+ exp(x_betahat2)+1);
    gen prob1=exp(x_betahat1)/(exp(x_betahat1)+ exp(x_betahat3)+1);
    gen prob2=exp(x_betahat2)/(exp(x_betahat0)+ exp(x_betahat2)+1);
    gen prob3=exp(x_betahat3)/(exp(x_betahat1)+ exp(x_betahat3)+1);

    gen diff1=prob1-prob0;
    gen diff2=prob3-prob2;
      
    egen probhat0=mean(prob0);
    egen  probhat1=mean(prob1);
    egen probhat2=mean(prob2);
    egen  probhat3=mean(prob3);
   
    egen diffhat1=mean(diff1);
    egen diffhat2=mean(diff2);
 
    _pctile prob0, p(2.5,97.5) ;
    scalar lo0 = r(r1);
    scalar hi0 = r(r2);  

    
    _pctile prob1, p(2.5,97.5);
     scalar lo1= r(r1);
     scalar hi1= r(r2);  
    

 
    _pctile prob2, p(2.5,97.5) ;
     scalar lo2= r(r1);
     scalar hi2= r(r2);  
    

    
    _pctile prob3, p(2.5,97.5);
     scalar lo3= r(r1);
     scalar hi3= r(r2);  
    

 
   _pctile diff1, p(2.5,97.5);
     scalar diff_lo1= r(r1);
     scalar diff_hi1= r(r2);  
 

    _pctile diff2, p(2.5,97.5);
       scalar diff_lo2= r(r1);
       scalar diff_hi2= r(r2);  

 
     scalar diff_hat1=diffhat1;
     scalar diff_hat2=diffhat2;
 

 
    post mypost (diff_hat1) (diff_hat2) (diff_lo1) (diff_hi1) (diff_lo2) (diff_hi2) ;        

    drop x_betahat0 x_betahat1 x_betahat2 x_betahat3 prob0 prob1 prob2 prob3 diff1 diff2 probhat0 probhat1 probhat2 probhat3 diffhat1 diffhat2 ;

 local a=`a'+ 1 ;
    display "." _c;
    } ;

display "";

postclose mypost;
#delimit;
use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", clear;

gen index= _n-1;
gen MV= index;


graph twoway line diff_hat2 MV, clwidth(medium) clcolor(blue) clcolor(black)
        ||   line diff_lo2  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line diff_hi2  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            xlabel(0 5 10 15 20)
            yscale(noline)
            xscale(noline)
            yline(0)
            title("2c.Rebel Finance", pos(11))
            legend(pos(1) col(1) label(1 "Effect of rebel finance on Gov intervention") 
                   label(2 "95% confidence interval") 
                  order(1 2) region(lstyle(none)))
            xtitle(Polity Score, size(4)  )
            ytitle("Effect of Rebel Finance", size(4))
            xsca(titlegap(2))
            ysca(titlegap(2))
            scheme(s2mono) graphregion(fcolor(white))
            name(PGovdrug,replace);

#delimit;
graph twoway line diff_hat1  MV, clwidth(medium) clcolor(blue) clcolor(black)
        ||   line diff_lo1  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line diff_hi1  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            
            xlabel(0 5 10 15 20)
            yscale(noline)
            xscale(noline)
            yline(0)
            title("1c.Rebel Finance", pos(11))
            legend(pos(1) col(1) label(1 "Effect of rebel finance on Rebel Intervention") 
                   label(2 "95% confidence interval") 
                  order(1 2) region(lstyle(none)))
            
            xtitle(Polity Score, size(4)  )
            ytitle("Effect of Rebel Finance", size(4))
            xsca(titlegap(2))
            ysca(titlegap(2))
            scheme(s2mono) graphregion(fcolor(white))
            name(PRebeldrug,replace);

*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*                 END                                                   *;
*     ****************************************************************  *; 
*     ****************************************************************  *;
*     ****************************************************************  *;



* ************************************************** *;
* ************************************************** *;
* Drugs /Winning Coalition                           *;
* ************************************************** *;
* ************************************************** *;
#delimit; 
use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\FYP_data_May2010_v1.dta", clear; 
xtset id year;

estsimp mlogit  typeint third_W  drugs inter1_4 lratio ally lndistance colhist Coldwar 
 premilint con_polity third_polity spellmili  _spline*  , sims(10000) robust cluster(id) nolog;


postutil clear;
postfile mypost diff_hat1 diff_hat2 diff_lo1 diff_hi1 diff_lo2 diff_hi2 
    using "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", replace;
noisily display "start";

local a= 0;
while `a' <=1 { ;

scalar h_lratio= -1.058528;
scalar h_drugs=0;
scalar h_ally= 0;
scalar h_third_polity=8; 
scalar h_lndistance=8.297453 ;
scalar h_distance=4937.091;
scalar h_colhist=0; 
scalar h_Coldwar=1; 
scalar h_conf_W=.5;
scalar h_war=0; 
scalar h_premilint=0; 
scalar h_spellmili=9.207655;
scalar h_spellmili2= 172.6125;
scalar h_spellmili3= 4447.729;
scalar h_constant=1;


  generate x_betahat0 = b1*(`a')
                            + b2*h_drugs
                            + b3*h_drugs*(`a')
                            + b4*h_lratio
                            + b5*h_ally
                            + b6*h_lndistance
                            + b7*h_colhist
                            + b8*h_Coldwar
                            + b9*h_premilint
                            + b10*h_con_polity
                            + b11*h_third_polity
                            + b12*h_spellmili  
                            + b13*h_spline1
                            + b14*h_spline2 
                            + b15*h_spline3
                            + b16*h_constant;

  
    generate x_betahat1 = b1*(`a')
                            + b2*(h_drugs +1)
                            + b3*(h_drugs +1)*(`a')
                            + b4*h_lratio
                            + b5*h_ally
                            + b6*h_lndistance
                            + b7*h_colhist
                            + b8*h_Coldwar
                            + b9*h_premilint
                            + b10*h_con_polity
                             + b11*h_third_polity
                            + b12*h_spellmili  
                            + b13*h_spline1
                            + b14*h_spline2 
                            + b15*h_spline3
                            + b16*h_constant;



 generate x_betahat2 =  b17*(`a')
                            + b18*h_drugs
                            + b19*h_drugs*(`a')
                            + b20*h_lratio
                            + b21*h_ally
                            + b22*h_lndistance
                            + b23*h_colhist
                            + b24*h_Coldwar
                            + b25*h_premilint
                            + b26*h_con_polity
                            + b27*h_third_polity
                            + b28*h_spellmili  
                            + b29*h_spline1
                            + b30*h_spline2 
                            + b31*h_spline3
                            + b32*h_constant;


    generate x_betahat3 = b17*(`a')
                            + b18*(h_drugs +1)
                            + b19*(h_drugs +1)*(`a')
                            + b20*h_lratio
                            + b21*h_ally
                            + b22*h_lndistance
                            + b23*h_colhist
                            + b24*h_Coldwar
                            + b25*h_premilint
                            + b26*h_con_polity
                            + b27*h_third_polity
                            + b28*h_spellmili  
                            + b29*h_spline1
                            + b30*h_spline2 
                            + b31*h_spline3
                            + b32*h_constant;

            
    gen prob0=exp(x_betahat0)/(exp(x_betahat0)+ exp(x_betahat2)+1);
    gen prob1=exp(x_betahat1)/(exp(x_betahat1)+ exp(x_betahat3)+1);
    gen prob2=exp(x_betahat2)/(exp(x_betahat0)+ exp(x_betahat2)+1);
    gen prob3=exp(x_betahat3)/(exp(x_betahat1)+ exp(x_betahat3)+1);

    gen diff1=prob1-prob0;
    gen diff2=prob3-prob2;
      
    egen probhat0=mean(prob0);
    egen  probhat1=mean(prob1);
    egen probhat2=mean(prob2);
    egen  probhat3=mean(prob3);
   
    egen diffhat1=mean(diff1);
    egen diffhat2=mean(diff2);
 
    _pctile prob0, p(2.5,97.5) ;
    scalar lo0 = r(r1);
    scalar hi0 = r(r2);  

    
    _pctile prob1, p(2.5,97.5);
     scalar lo1= r(r1);
     scalar hi1= r(r2);  
    

 
    _pctile prob2, p(2.5,97.5) ;
     scalar lo2= r(r1);
     scalar hi2= r(r2);  
    

    
    _pctile prob3, p(2.5,97.5);
     scalar lo3= r(r1);
     scalar hi3= r(r2);  
    

 
   _pctile diff1, p(2.5,97.5);
     scalar diff_lo1= r(r1);
     scalar diff_hi1= r(r2);  
 

    _pctile diff2, p(2.5,97.5);
       scalar diff_lo2= r(r1);
       scalar diff_hi2= r(r2);  

 
     scalar diff_hat1=diffhat1;
     scalar diff_hat2=diffhat2;
 

 
    post mypost (diff_hat1) (diff_hat2) (diff_lo1) (diff_hi1) (diff_lo2) (diff_hi2) ;        

    drop x_betahat0 x_betahat1 x_betahat2 x_betahat3 prob0 prob1 prob2 prob3 diff1 diff2 probhat0 probhat1 probhat2 probhat3 diffhat1 diffhat2 ;

 local a=`a'+ .05 ;
    display "." _c;
    } ;

display "";

postclose mypost;
#delimit;
use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", clear;

gen index= _n-1;
gen MV= index/20;


graph twoway line diff_hat2 MV, clwidth(medium) clcolor(blue) clcolor(black)
        ||   line diff_lo2  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line diff_hi2  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            xlabel(0 .25 .5 .75  1)
            yscale(noline)
            xscale(noline)
            yline(0)
            title("2d.Rebel Finance", pos(11))
            legend(pos(1) col(1) label(1 "Effect of rebel finance on Gov intervention") 
                   label(2 "95% confidence interval") 
                  order(1 2) region(lstyle(none)))
            xtitle(Winning Coalition Size, size(4)  )
            ytitle("Effect of Rebel Finance", size(4))
            xsca(titlegap(2))
            ysca(titlegap(2))
            scheme(s2mono) graphregion(fcolor(white))
            name(WGovdrug,replace);

#delimit;
graph twoway line diff_hat1  MV, clwidth(medium) clcolor(blue) clcolor(black)
        ||   line diff_lo1  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line diff_hi1  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            
            xlabel(0 .25 .5 .75  1)
            yscale(noline)
            xscale(noline)
            yline(0)
            title("1d.Rebel Finance", pos(11))
            legend(pos(1) col(1) label(1 "Effect of rebel finance on Rebel Intervention") 
                   label(2 "95% confidence interval") 
                  order(1 2) region(lstyle(none)))
            
            xtitle(Winning Coalition Size, size(4)  )
            ytitle("Effect of Rebel Finance", size(4))
            xsca(titlegap(2))
            ysca(titlegap(2))
            scheme(s2mono) graphregion(fcolor(white))
            name(WRebeldrug,replace);

*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*                 END                                                   *;
*     ****************************************************************  *; 
*     ****************************************************************  *;
*     ****************************************************************  *;




* ******************************************************************** *; 
* ******************************************************************** *;
* Combine Graphs                                                       *; 
* ******************************************************************** *;
* ******************************************************************** *;

#delimit;
graph combine PRebelstreb WRebelstreb ,  iscale(*.9) imargin(small) ysize(6) xsize(8) col(2) 
   name(fig1, replace) saving(fig1, replace);


#delimit;
graph combine PGovstreb WGovstreb,  iscale(*.9) imargin(small) ysize(6) xsize(8) col(2) 
      name(memo2, replace) saving(memo2, replace);


#delimit;
graph combine PRebeldrug WRebeldrug ,  iscale(*.9) imargin(small) ysize(6) xsize(8) col(2) 
      name(memo1, replace) saving(memo1, replace);


* ************************************************** *;
* ************************************************** *;
* ************************************************** *;
* ************************************************** *;
* Ethnic Hypothesis                                  *;
* ************************************************** *;
* ************************************************** *;
* ************************************************** *;
* ************************************************** *;

* ********************************************************************* *;
* ********************************************************************* *;
* ********************************************************************* *;
* DomMar  (log_distance)                                                *;
* ********************************************************************* *;
* ********************************************************************* *;
* ********************************************************************* *;
#delimit;
use  "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\FYP_data_May2010_v1.dta", clear;
xtset id year;


#delimit;

estsimp mlogit  typeint third_polity  reb_relstr DomDom inter2_11 DomMar inter2_13 
   lratio ally lndistance colhist Coldwar premilint con_polity spellmili _spline* ,sims(10000) robust cluster(id) nolog;


#delimit;
postutil clear;
postfile mypost diff_hat1 diff_hat2 diff_lo1 diff_hi1 diff_lo2 diff_hi2 
    using "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", replace;
noisily display "start";


local a= 0;
while `a' <= 20 { ;


scalar h_lratio= -1.058528;
scalar h_drugs=0;
scalar h_DomDom=0;
scalar h_DomMar=0;
scalar h_reb_relstr=2; 
scalar h_con_polity=7;
scalar h_Mar=0;
scalar h_ally= 0;
scalar h_lndistance=8.297453 ;
scalar h_distance=4937.091;
scalar h_colhist=0; 
scalar h_Coldwar=1; 
scalar h_premilint=0; 
scalar h_spellmili=9.207655;
scalar h_spellmili2= 172.6125;
scalar h_spellmili3= 4447.729;
scalar h_spline1= -757.8112; 
scalar h_spline2= -1763.558; 
scalar h_spline3= -2452.633; 
scalar h_constant=1;



    generate x_betahat0 = b1*(`a')
                            + b2*h_reb_relstr 
                            + b3*h_DomDom
                            + b4*h_DomDom*(`a')
                            + b5*h_DomMar 
                            + b6*h_DomMar*(`a')
                            + b7*h_lratio
                            + b8*h_ally
                            + b9*h_lndistance
                            + b10*h_colhist
                            + b11*h_Coldwar
                            + b12*h_premilint
                            + b13*h_con_polity
                            + b14*h_spellmili 
                            + b15*h_spline1 
                            + b16*h_spline2
                            + b17*h_spline3
                            + b18*h_constant;

        
    generate x_betahat1 = b1*(`a')
                            + b2*h_reb_relstr 
                            + b3*h_DomDom
                            + b4*h_DomDom*(`a')
                            + b5*(h_DomMar +1)
                            + b6*(h_DomMar +1)*(`a')
                            + b7*h_lratio
                            + b8*h_ally
                            + b9*h_lndistance
                            + b10*h_colhist
                            + b11*h_Coldwar
                            + b12*h_premilint
                            + b13*h_con_polity
                            + b14*h_spellmili 
                            + b15*h_spline1 
                            + b16*h_spline2
                            + b17*h_spline3
                            + b18*h_constant;

        
 generate x_betahat2 = b19*(`a')
                            + b20*h_reb_relstr 
                            + b21*h_DomDom
                            + b22*h_DomDom*(`a')
                            + b23*h_DomMar 
                            + b24*h_DomMar*(`a')
                            + b25*h_lratio
                            + b26*h_ally
                            + b27*h_lndistance
                            + b28*h_colhist
                            + b29*h_Coldwar
                            + b30*h_premilint
                            + b31*h_con_polity
                            + b32*h_spellmili 
                            + b33*h_spline1 
                            + b34*h_spline2
                            + b35*h_spline3
                            + b36*h_constant;


    generate x_betahat3 =  b19*(`a')
                            + b20*h_reb_relstr 
                            + b21*h_DomDom
                            + b22*h_DomDom*(`a')
                            + b23*(h_DomMar +1)
                            + b24*(h_DomMar +1)*(`a')
                            + b25*h_lratio
                            + b26*h_ally
                            + b27*h_lndistance
                            + b28*h_colhist
                            + b29*h_Coldwar
                            + b30*h_premilint
                            + b31*h_con_polity
                            + b32*h_spellmili 
                            + b33*h_spline1 
                            + b34*h_spline2
                            + b35*h_spline3
                            + b36*h_constant;


    gen prob0=exp(x_betahat0)/(exp(x_betahat0)+ exp(x_betahat2)+1);
    gen prob1=exp(x_betahat1)/(exp(x_betahat1)+ exp(x_betahat3)+1);
    gen prob2=exp(x_betahat2)/(exp(x_betahat0)+ exp(x_betahat2)+1);
    gen prob3=exp(x_betahat3)/(exp(x_betahat1)+ exp(x_betahat3)+1);

    gen diff1=prob1-prob0;
    gen diff2=prob3-prob2;
      
    egen probhat0=mean(prob0);
    egen  probhat1=mean(prob1);
    egen probhat2=mean(prob2);
    egen  probhat3=mean(prob3);
   
    egen diffhat1=mean(diff1);
    egen diffhat2=mean(diff2);
 

    _pctile prob0, p(2.5,97.5) ;
    scalar lo0 = r(r1);
    scalar hi0 = r(r2);  

    
    _pctile prob1, p(2.5,97.5);
     scalar lo1= r(r1);
     scalar hi1= r(r2);  
    

 
    _pctile prob2, p(2.5,97.5) ;
     scalar lo2= r(r1);
     scalar hi2= r(r2);  
    

    
    _pctile prob3, p(2.5,97.5);
     scalar lo3= r(r1);
     scalar hi3= r(r2);  
    

 
   _pctile diff1, p(2.5,97.5);
     scalar diff_lo1= r(r1);
     scalar diff_hi1= r(r2);  
 

    _pctile diff2, p(2.5,97.5);
       scalar diff_lo2= r(r1);
       scalar diff_hi2= r(r2);  

 
     scalar diff_hat1=diffhat1;
     scalar diff_hat2=diffhat2;
 

 
    post mypost (diff_hat1) (diff_hat2) (diff_lo1) (diff_hi1) (diff_lo2) (diff_hi2) ;        

    drop x_betahat0 x_betahat1 x_betahat2 x_betahat3 prob0 prob1 prob2 prob3 diff1 diff2 probhat0 probhat1 probhat2 probhat3 diffhat1 diffhat2 ;

 local a=`a'+ 1 ;
    display "." _c;
    } ;
display "";
postclose mypost;

#delimit;
use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", clear;

gen index= _n-1;
gen MV= index;

graph twoway line diff_hat1  MV, clwidth(medium) clcolor(blue) clcolor(black)
        ||   line diff_lo1  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line diff_hi1  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            
            xlabel(0 5 10 15 20)
            yscale(noline)
            xscale(noline)
            yline(0)
            legend(pos(11) col(1) label(1 "Effect of ethnic-tie on Rebel Intervention")
                  label(2 "95% confidence interval")  
                  order(1 2) region(lstyle(none)))

            xtitle(Polity Score, size(4)  )
            ytitle("Effect of ethnic-tie with opposition group", size(4))
            xsca(titlegap(2))
            ysca(titlegap(2))
            scheme(s2mono) graphregion(fcolor(white))
            name(PRebelmar,replace);
       
#delimit;
use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", clear;

gen index= _n-1;
gen MV=index;

graph twoway line diff_hat2  MV, clwidth(medium) clcolor(blue) clcolor(black)
        ||   line diff_lo2  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line diff_hi2  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            
            xlabel(0 5 10 15 20 )
            yscale(noline)
            xscale(noline)
            yline(0)
            legend(pos(11) col(1) label(1 "Effect of ethnic-tie with opposition group")
                  label(2 "95% confidence interval")  
                  order(1 2) region(lstyle(none)))

            xtitle(Polity Score, size(4)  )
            ytitle("Effect of ethnic-tie with opposition group", size(4))
            xsca(titlegap(2))
            ysca(titlegap(2))
            scheme(s2mono) graphregion(fcolor(white))
            name(PGovmar,replace);
       


*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*                 Figure can be saved in a variety of formats.          *;
*     ****************************************************************  *; 
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;


* ****************************************************************** *;
* ****************************************************************** *;
* ****************************************************************** *;
* DomMar/Winning Coalition                                           *;
* ****************************************************************** *;
* ****************************************************************** *;
* ****************************************************************** *;

#delimit;
use  "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\FYP_data_May2010_v1.dta", clear;

xtset id year;

#delimit;
estsimp mlogit  typeint third_W  reb_relstr  inter5_14 DomDom inter2_12 DomMar inter2_14 
 lratio ally lndistance colhist Coldwar premilint con_polity third_polity
spellmili  _spline*   ,sims(10000) robust cluster(id) nolog;


#delimit;
postutil clear;
postfile mypost diff1 diff2 diff_hat1 diff_hat2 diff_lo1 diff_hi1 diff_lo2 diff_hi2 
    using "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", replace;
noisily display "start";


local a= 0;
while `a' <= 1 { ;


scalar h_lratio= -1.058528;
scalar h_reb_relstr=2; 
scalar h_drugs=0;
scalar h_third_polity=8; 
scalar h_DomDom=0;
scalar h_DomMar=0;
scalar h_premilint=0 ; 
scalar h_Mar=0;
scalar h_ally= 0;
scalar h_con_polity=7;
scalar h_lndistance=8.297453 ;
scalar h_colhist=0; 
scalar h_Coldwar=1; 
scalar h_spellmili=9.207655;
scalar h_spellmili2= 172.6125;
scalar h_spellmili3= 4447.729;
scalar h_spline1= -757.8112; 
scalar h_spline2= -1763.558; 
scalar h_spline3= -2452.633; 
scalar h_constant=1;


    generate x_betahat0 = b1*(`a')
                            + b2*h_reb_relstr
                            + b3*h_reb_relstr*(`a')
                            + b4*h_DomDom
                            + b5*h_DomDom*(`a')
                            + b6*h_DomMar 
                            + b7*h_DomMar*(`a')
                            + b8*h_lratio
                            + b9*h_ally
                            + b10*h_lndistance
                            + b11*h_colhist
                            + b12*h_Coldwar
                            + b13*h_premilint
                            + b14*h_con_polity
                            + b15*h_third_polity
                            + b16*h_spellmili  
                            + b17*h_spline1
                            + b18*h_spline2
                            + b19*h_spline3
                            + b20*h_constant;

     
    generate x_betahat1 =  b1*(`a')
                            + b2*h_reb_relstr
                            + b3*h_reb_relstr*(`a')
                            + b4*h_DomDom
                            + b5*h_DomDom*(`a')
                            + b6*(h_DomMar +1) 
                            + b7*(h_DomMar +1)*(`a')
                            + b8*h_lratio
                            + b9*h_ally
                            + b10*h_lndistance
                            + b11*h_colhist
                            + b12*h_Coldwar
                            + b13*h_premilint
                            + b14*h_con_polity
                            + b15*h_third_polity
                            + b16*h_spellmili  
                            + b17*h_spline1
                            + b18*h_spline2
                            + b19*h_spline3
                            + b20*h_constant;

     
            
 generate x_betahat2 = b21*(`a')
                            + b22*h_reb_relstr 
                            + b23*h_reb_relstr*(`a')
                            + b24*h_DomDom
                            + b25*h_DomDom*(`a')
                            + b26*h_DomMar 
                            + b27*h_DomMar*(`a')
                            + b28*h_lratio
                            + b29*h_ally
                            + b30*h_lndistance
                            + b31*h_colhist
                            + b32*h_Coldwar
                            + b33*h_premilint
                            + b34*h_con_polity
                            + b35*h_third_polity
                            + b36*h_spellmili  
                            + b37*h_spline1
                            + b38*h_spline2
                            + b39*h_spline3
                            + b40*h_constant;


    generate x_betahat3 = b21*(`a')
                            + b22*h_reb_relstr 
                            + b23*h_reb_relstr*(`a')
                            + b24*h_DomDom
                            + b25*h_DomDom*(`a')
                            + b26*(h_DomMar +1)
                            + b27*(h_DomMar +1)*(`a')
                            + b28*h_lratio
                            + b29*h_ally
                            + b30*h_lndistance
                            + b31*h_colhist
                            + b32*h_Coldwar
                            + b33*h_premilint
                            + b34*h_con_polity
                            + b35*h_third_polity
                            + b36*h_spellmili  
                            + b37*h_spline1
                            + b38*h_spline2
                            + b39*h_spline3
                            + b40*h_constant;


    gen prob0=exp(x_betahat0)/(exp(x_betahat0)+ exp(x_betahat2)+1);
    gen prob1=exp(x_betahat1)/(exp(x_betahat1)+ exp(x_betahat3)+1);
    gen prob2=exp(x_betahat2)/(exp(x_betahat0)+ exp(x_betahat2)+1);
    gen prob3=exp(x_betahat3)/(exp(x_betahat1)+ exp(x_betahat3)+1);

    gen diff1=prob1-prob0;
    gen diff2=prob3-prob2;
      
    egen probhat0=mean(prob0);
    egen  probhat1=mean(prob1);
    egen probhat2=mean(prob2);
    egen  probhat3=mean(prob3);
   
    egen diffhat1=mean(diff1);
    egen diffhat2=mean(diff2);
 

    _pctile prob0, p(2.5,97.5) ;
    scalar lo0 = r(r1);
    scalar hi0 = r(r2);  

    
    _pctile prob1, p(2.5,97.5);
     scalar lo1= r(r1);
     scalar hi1= r(r2);  
    

    _pctile prob2, p(2.5,97.5) ;
     scalar lo2= r(r1);
     scalar hi2= r(r2);  
    
    _pctile prob3, p(2.5,97.5);
     scalar lo3= r(r1);
     scalar hi3= r(r2);  
    
   _pctile diff1, p(2.5,97.5);
     scalar diff_lo1= r(r1) ;
     scalar diff_hi1= r(r2) ;  

    _pctile diff2, p(2.5,97.5);
       scalar diff_lo2= r(r1) ;
       scalar diff_hi2= r(r2) ;  

 
     scalar diff_hat1=diffhat1;
     scalar diff_hat2=diffhat2;
  
    post mypost (diff1) (diff2) (diff_hat1) (diff_hat2) (diff_lo1) (diff_hi1) (diff_lo2) (diff_hi2) ;        

    drop x_betahat0 x_betahat1 x_betahat2 x_betahat3 prob0 prob1 prob2 prob3 diff1 diff2 probhat0 probhat1 probhat2 probhat3 diffhat1 diffhat2 ;

 local a=`a'+ .05 ;
    display "." _c;
    } ;
display "";
postclose mypost;
  
                           
#delimit;
use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", clear;

gen index= _n-1;
gen MV= index/20;

#delimit;
graph twoway line diff_hat2 MV, clwidth(medium) clcolor(blue) clcolor(black)
        ||   line diff_lo2  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line diff_hi2  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            
            xlabel(0 .25 .5 .75  1)
            yscale(noline)
            xscale(noline)
            yline(0)  
            legend(pos(11) col(1) label(1 "Effect of ethnic-tie on Government Intervention") 
                   label(2 "95% confidence interval") 
                   order(1 2) region(lstyle(none)))
            xtitle(Winning Coalition Size, size(4))
            ytitle("Effect of ethnic-tie with Dominant group", size(4))
            xsca(titlegap(2))
            ysca(titlegap(2))
            scheme(s2mono) graphregion(fcolor(white))
            name(WGovmar,replace);


#delimit;
graph twoway line diff_hat1 MV, clwidth(medium) clcolor(blue) clcolor(black)
        ||   line diff_lo1  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line diff_hi1  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            
            xlabel(0 .25 .5 .75  1)
            yscale(noline)
            xscale(noline)
            yline(0)
            
            legend(pos(11) col(1) label(1 "Effect of ethnic-tie on Rebel Intervention") 
                   label(2 "95% confidence interval") 
                   order(1 2) region(lstyle(none)))
            xtitle(Winning Coalition Size, size(4))
            ytitle("Effect of ethnic-tie with Opposition group", size(4))
            xsca(titlegap(2))
            ysca(titlegap(2))
            scheme(s2mono) graphregion(fcolor(white))
            name(WRebelmar,replace);



*     ****************************************************************  *;
*                 Figure can be saved in a variety of formats.          *;
*     ****************************************************************  *; 

*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*                                   THE END                             *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;


****************************************************************** *;
* ****************************************************************** *;
* DomDom/Polity  (I include con_polity)                              *;
* ****************************************************************** *;
* ****************************************************************** *;
* ****************************************************************** *;

#delimit;
use  "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\FYP_data_May2010_v1.dta", clear;

xtset id year;

#delimit;
estsimp mlogit  typeint third_polity  reb_relstr DomDom inter2_11 DomMar inter2_13 
  lratio ally lndistance colhist Coldwar premilint con_polity spellmili _spline* 
,sims(10000) robust cluster(id) nolog;

#delimit;
postutil clear;
postfile mypost diff1 diff2 diff_hat1 diff_hat2 diff_lo1 diff_hi1 diff_lo2 diff_hi2 
    using "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", replace;
noisily display "start";


local a= 0;
while `a' <= 20 { ;


scalar h_lratio= -1.058528;
scalar h_drugs=0;
scalar h_DomDom=0;
scalar h_DomMar=0;
scalar h_premilint=0; 
scalar h_reb_relstr=2; 
scalar h_Mar=0;
scalar h_ally= 0;
scalar h_lndistance=8.297453 ;
scalar h_colhist=0; 
scalar h_Coldwar=1;
scalar h_con_polity=7;  
scalar h_spellmili=9.207655;
scalar h_spellmili2= 172.6125;
scalar h_spellmili3= 4447.729;
scalar h_spline1= -757.8112; 
scalar h_spline2= -1763.558; 
scalar h_spline3= -2452.633; 
scalar h_constant=1;


    generate x_betahat0 = b1*(`a')
                            + b2*h_reb_relstr 
                            + b3*h_DomDom
                            + b4*h_DomDom*(`a')
                            + b5*h_DomMar 
                            + b6*h_DomMar*(`a')
                            + b7*h_lratio
                            + b8*h_ally
                            + b9*h_lndistance
                            + b10*h_colhist
                            + b11*h_Coldwar
                            + b12*h_premilint 
                            + b13*h_con_polity
                            + b14*h_spellmili 
                            + b15*h_spline1 
                            + b16*h_spline2
                            + b17*h_spline3
                            + b18*h_constant;
     
    generate x_betahat1 = b1*(`a')
                            + b2*h_reb_relstr 
                            + b3*(h_DomDom +1)
                            + b4*(h_DomDom +1)*(`a')
                            + b5*h_DomMar 
                            + b6*h_DomMar*(`a')
                            + b7*h_lratio
                            + b8*h_ally
                            + b9*h_lndistance
                            + b10*h_colhist
                            + b11*h_Coldwar
                            + b12*h_premilint 
                            + b13*h_con_polity
                            + b14*h_spellmili 
                            + b15*h_spline1 
                            + b16*h_spline2
                            + b17*h_spline3
                            + b18*h_constant;
     

            
 generate x_betahat2 = b19*(`a')
                            + b20*h_reb_relstr
                            + b21*h_DomDom
                            + b22*h_DomDom*(`a')
                            + b23*h_DomMar 
                            + b24*h_DomMar*(`a')
                            + b25*h_lratio
                            + b26*h_ally
                            + b27*h_lndistance
                            + b28*h_colhist
                            + b29*h_Coldwar
                            + b30*h_premilint 
                            + b31*h_con_polity
                            + b32*h_spellmili 
                            + b33*h_spline1 
                            + b34*h_spline2
                            + b35*h_spline3
                            + b36*h_constant;


    generate x_betahat3 =  b19*(`a')
                            + b20*h_reb_relstr
                            + b21*(h_DomDom +1)
                            + b22*(h_DomDom +1)*(`a')
                            + b23*h_DomMar 
                            + b24*h_DomMar*(`a')
                            + b25*h_lratio
                            + b26*h_ally
                            + b27*h_lndistance
                            + b28*h_colhist
                            + b29*h_Coldwar
                            + b30*h_premilint 
                            + b31*h_con_polity
                            + b32*h_spellmili 
                            + b33*h_spline1 
                            + b34*h_spline2
                            + b35*h_spline3
                            + b36*h_constant;
 
                                                  
    gen prob0=exp(x_betahat0)/(exp(x_betahat0)+ exp(x_betahat2)+1);
    gen prob1=exp(x_betahat1)/(exp(x_betahat1)+ exp(x_betahat3)+1);
    gen prob2=exp(x_betahat2)/(exp(x_betahat0)+ exp(x_betahat2)+1);
    gen prob3=exp(x_betahat3)/(exp(x_betahat1)+ exp(x_betahat3)+1);

    gen diff1=prob1-prob0;
    gen diff2=prob3-prob2;
      
    egen probhat0=mean(prob0);
    egen  probhat1=mean(prob1);
    egen probhat2=mean(prob2);
    egen  probhat3=mean(prob3);
   
    egen diffhat1=mean(diff1);
    egen diffhat2=mean(diff2);
 

    _pctile prob0, p(2.5, 97.5) ;
    scalar lo0 = r(r1);
    scalar hi0 = r(r2);  

    
    _pctile prob1, p(2.5, 97.5);
     scalar lo1= r(r1);
     scalar hi1= r(r2);  
    

    _pctile prob2, p(2.5, 97.5) ;
     scalar lo2= r(r1);
     scalar hi2= r(r2);  
    
    _pctile prob3, p(2.5, 97.5);
     scalar lo3= r(r1);
     scalar hi3= r(r2);  
    
   _pctile diff1, p(2.5, 97.5);
     scalar diff_lo1= r(r1) ;
     scalar diff_hi1= r(r2) ;  

    _pctile diff2, p(2.5, 97.5);
       scalar diff_lo2= r(r1) ;
       scalar diff_hi2= r(r2) ;  

 
     scalar diff_hat1=diffhat1;
     scalar diff_hat2=diffhat2;
  
    post mypost (diff1) (diff2) (diff_hat1) (diff_hat2) (diff_lo1) (diff_hi1) (diff_lo2) (diff_hi2) ;        

    drop x_betahat0 x_betahat1 x_betahat2 x_betahat3 prob0 prob1 prob2 prob3 diff1 diff2 probhat0 probhat1 probhat2 probhat3 diffhat1 diffhat2 ;

 local a=`a'+ 1 ;
    display "." _c;
    } ;
display "";
postclose mypost;
  
                           
#delimit;
use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", clear;

gen index= _n-1;
gen MV= index;

#delimit;
graph twoway line diff_hat2 MV, clwidth(medium) clcolor(blue) clcolor(black)
        ||   line diff_lo2  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line diff_hi2  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            
            xlabel(0 5 10 15 20)
            yscale(noline)
            xscale(noline)
            yline(0)
         
            legend(pos(11) col(1) label(1 "Effect of ethnic-tie on Government Intervention") 
                   label(2 "95% confidence interval") 
                   order(1 2) region(lstyle(none)))
            xtitle(Polity Score, size(4))
            ytitle("Effect of ethnic-tie with Dominant group", size(4))
            xsca(titlegap(2))
            ysca(titlegap(2))
            scheme(s2mono) graphregion(fcolor(white))
            name(PGovdom,replace);


#delimit;
graph twoway line diff_hat1 MV, clwidth(medium) clcolor(blue) clcolor(black)
        ||   line diff_lo1  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line diff_hi1  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            
            xlabel(0 5 10 15 20)
            yscale(noline)
            xscale(noline)
            yline(0)
            legend(pos(11) col(1) label(1 "Effect of ethnic-tie with Dominant group") 
                   label(2 "95% confidence interval") 
                   order(1 2) region(lstyle(none)))
            xtitle(Polity Score, size(4))
            ytitle("Effect of ethnic-tie with Dominant group", size(4))
            xsca(titlegap(2))
            ysca(titlegap(2))
            scheme(s2mono) graphregion(fcolor(white))
            name(PRebdom,replace);

*     ****************************************************************  *;
*                 Figure can be saved in a variety of formats.          *;
*     ****************************************************************  *; 

*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*                                   THE END                             *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;



* ****************************************************************** *;
* ****************************************************************** *;
* ****************************************************************** *;
* DomDom/Winning Coalition                                           *;
* ****************************************************************** *;
* ****************************************************************** *;
* ****************************************************************** *;

#delimit;
use  "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\FYP_data_May2010_v1.dta", clear;

xtset id year;

#delimit;
estsimp mlogit  typeint third_W  reb_relstr inter5_14 DomDom inter2_12 DomMar inter2_14 
 lratio ally lndistance colhist Coldwar premilint con_polity third_polity
spellmili  _spline* ,sims(10000) robust cluster(id) nolog;


#delimit;
postutil clear;
postfile mypost diff1 diff2 diff_hat1 diff_hat2 diff_lo1 diff_hi1 diff_lo2 diff_hi2 
    using "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", replace;
noisily display "start";


local a= 0;
while `a' <= 1 { ;


scalar h_lratio= -1.058528;
scalar h_drugs=0;
scalar h_third_polity=8; 
scalar h_reb_relstr=2; 
scalar h_DomDom=0;
scalar h_DomMar=0;
scalar h_premilint=0 ; 
scalar h_Mar=0;
scalar h_ally= 0;
scalar h_lndistance=8.297453 ;
scalar h_colhist=0; 
scalar h_Coldwar=1; 
scalar h_spellmili=9.207655;
scalar h_spellmili2= 172.6125;
scalar h_spellmili3= 4447.729;
scalar h_spline1= -757.8112; 
scalar h_spline2= -1763.558; 
scalar h_spline3= -2452.633; 
scalar h_constant=1;


    generate x_betahat0 = b1*(`a')
                            + b2*h_reb_relstr  
                            + b3*h_reb_relstr*(`a')
                            + b4*h_DomDom
                            + b5*h_DomDom*(`a')
                            + b6*h_DomMar 
                            + b7*h_DomMar*(`a')
                            + b8*h_lratio
                            + b9*h_ally
                            + b10*h_lndistance
                            + b11*h_colhist
                            + b12*h_Coldwar
                            + b13*h_premilint
                            + b14*h_con_polity
                            + b15*h_third_polity
                            + b16*h_spellmili  
                            + b17*h_spline1
                            + b18*h_spline2
                            + b19*h_spline3
                            + b20*h_constant;

     
    generate x_betahat1 = b1*(`a')
                            + b2*h_reb_relstr  
                            + b3*h_reb_relstr*(`a')
                            + b4*(h_DomDom +1)
                            + b5*(h_DomDom +1)*(`a')
                            + b6*h_DomMar 
                            + b7*h_DomMar*(`a')
                            + b8*h_lratio
                            + b9*h_ally
                            + b10*h_lndistance
                            + b11*h_colhist
                            + b12*h_Coldwar
                            + b13*h_premilint
                            + b14*h_con_polity
                            + b15*h_third_polity
                            + b16*h_spellmili  
                            + b17*h_spline1
                            + b18*h_spline2
                            + b19*h_spline3
                            + b20*h_constant;



            
 generate x_betahat2 = b21*(`a')
                            + b22*h_reb_relstr
                            + b23*h_reb_relstr*(`a')
                            + b24*h_DomDom
                            + b25*h_DomDom*(`a')
                            + b26*h_DomMar 
                            + b27*h_DomMar*(`a')
                            + b28*h_lratio
                            + b29*h_ally
                            + b30*h_lndistance
                            + b31*h_colhist
                            + b32*h_Coldwar
                            + b33*h_premilint
                            + b34*h_con_polity
                            + b35*h_third_polity
                            + b36*h_spellmili  
                            + b37*h_spline1
                            + b38*h_spline2
                            + b39*h_spline3
                            + b40*h_constant;


          generate x_betahat3 = b21*(`a')
                            + b22*h_reb_relstr
                            + b23*h_reb_relstr*(`a')
                            + b24*(h_DomDom +1)
                            + b25*(h_DomDom +1)*(`a')
                            + b26*h_DomMar 
                            + b27*h_DomMar*(`a')
                            + b28*h_lratio
                            + b29*h_ally
                            + b30*h_lndistance
                            + b31*h_colhist
                            + b32*h_Coldwar
                            + b33*h_premilint
                            + b34*h_con_polity
                            + b35*h_third_polity
                            + b36*h_spellmili  
                            + b37*h_spline1
                            + b38*h_spline2
                            + b39*h_spline3
                            + b40*h_constant;





    gen prob0=exp(x_betahat0)/(exp(x_betahat0)+ exp(x_betahat2)+1);
    gen prob1=exp(x_betahat1)/(exp(x_betahat1)+ exp(x_betahat3)+1);
    gen prob2=exp(x_betahat2)/(exp(x_betahat0)+ exp(x_betahat2)+1);
    gen prob3=exp(x_betahat3)/(exp(x_betahat1)+ exp(x_betahat3)+1);

    gen diff1=prob1-prob0;
    gen diff2=prob3-prob2;
      
    egen probhat0=mean(prob0);
    egen  probhat1=mean(prob1);
    egen probhat2=mean(prob2);
    egen  probhat3=mean(prob3);
   
    egen diffhat1=mean(diff1);
    egen diffhat2=mean(diff2);
 

    _pctile prob0, p(2.5, 97.5) ;
    scalar lo0 = r(r1);
    scalar hi0 = r(r2);  

    
    _pctile prob1, p(2.5, 97.5);
     scalar lo1= r(r1);
     scalar hi1= r(r2);  
    

    _pctile prob2, p(2.5, 97.5) ;
     scalar lo2= r(r1);
     scalar hi2= r(r2);  
    
    _pctile prob3, p(2.5, 97.5);
     scalar lo3= r(r1);
     scalar hi3= r(r2);  
    
   _pctile diff1, p(2.5, 97.5);
     scalar diff_lo1= r(r1) ;
     scalar diff_hi1= r(r2) ;  

    _pctile diff2, p(2.5, 97.5);
       scalar diff_lo2= r(r1) ;
       scalar diff_hi2= r(r2) ;  

 
     scalar diff_hat1=diffhat1;
     scalar diff_hat2=diffhat2;
  
    post mypost (diff1) (diff2) (diff_hat1) (diff_hat2) (diff_lo1) (diff_hi1) (diff_lo2) (diff_hi2) ;        

    drop x_betahat0 x_betahat1 x_betahat2 x_betahat3 prob0 prob1 prob2 prob3 diff1 diff2 probhat0 probhat1 probhat2 probhat3 diffhat1 diffhat2 ;

 local a=`a'+ .05 ;
    display "." _c;
    } ;
display "";
postclose mypost;
  
                           
#delimit;
use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", clear;

gen index= _n-1;
gen MV= index/20;

#delimit;
graph twoway line diff_hat2 MV, clwidth(medium) clcolor(blue) clcolor(black)
        ||   line diff_lo2  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line diff_hi2  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            
            xlabel(0 .25 .5 .75  1)
            yscale(noline)
            xscale(noline)
            yline(0)
            
            legend(pos(11) col(1) label(1 "Effect of ethnic-tie on Government Intervention") 
                   label(2 "95% confidence interval") 
                   order(1 2) region(lstyle(none)))
            xtitle(Winning Coalition Size, size(4))
            ytitle("Effect of ethnic-tie with Dominant group", size(4))
            xsca(titlegap(2))
            ysca(titlegap(2))
            scheme(s2mono) graphregion(fcolor(white))
            name(WGovdom,replace);


#delimit;
graph twoway line diff_hat1 MV, clwidth(medium) clcolor(blue) clcolor(black)
        ||   line diff_lo1  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line diff_hi1  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            
            xlabel(0 .25 .5 .75  1)
            yscale(noline)
            xscale(noline)
            yline(0)
            legend(pos(11) col(1) label(1 "Effect of ethnic-tie with Dominant group") 
                   label(2 "95% confidence interval") 
                   order(1 2) region(lstyle(none)))
            xtitle(Winning Coalition Size, size(4))
            ytitle("Effect of ethnic-tie with Dominant group", size(4))
            xsca(titlegap(2))
            ysca(titlegap(2))
            scheme(s2mono) graphregion(fcolor(white))
            name(WRebdom,replace);

*     ****************************************************************  *;
*                 Figure can be saved in a variety of formats.          *;
*     ****************************************************************  *; 

*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*                                   THE END                             *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;








* ******************************************************************** *; 
* ******************************************************************** *;
* Combine Graphs                                                       *; 
* ******************************************************************** *;
* ******************************************************************** *;


#delimit;
graph combine PRebelmar  WRebelmar ,  iscale(*.9) imargin(small) ysize(6) xsize(8) col(2) 
        name(fig3, replace) saving(fig3, replace);


#delimit;
graph combine  PGovdom WGovdom ,  iscale(*.9) imargin(small) ysize(8) xsize(9) col(2) 
     name(fig4, replace) saving(fig4, replace);


* ************************************************** *;
* ************************************************** *;
* ************************************************** *;
* ************************************************** *;
* Probit Model                                       *;
* ************************************************** *;
* ************************************************** *;
* ************************************************** *;
* ************************************************** *;

* *********************************************************************** *;
* *********************************************************************** *;


* *********************************************************************** *;
* *********************************************************************** *;
* *********************************************************************** *;
* Lootable Resoruces                                                      *;
* *********************************************************************** *;
* *********************************************************************** *;
* *********************************************************************** *;
#delimit; 
 use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\FYP_data_May2010_v1.dta", clear ;

estsimp probit  mili_intervention  third_polity 
SDIAD inter3_3 ethltie inter2_19 lratio ally lndistance colhist Coldwar     
premilint spellmili spellmili2 spellmili3 , sims(10000) robust cluster(id) nolog;


postutil clear;
postfile mypost diff_hat diff_lo diff_hi
    using "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", replace;
noisily display "start";


local a= 0;
while `a' <= 20 { ;
    

scalar h_lratio= -1.058528;
scalar h_ethltie=0; 
scalar h_gempCNTR=0;
scalar h_SDIAD=0; 
scalar h_drugs=0;
scalar h_ally= 0;
scalar h_lndistance=8.297453 ;
scalar h_distance=4937.091;
scalar h_colhist=0; 
scalar h_lcap_2=-7.074035;
scalar h_premilint=0; 
scalar h_Coldwar=1; 
scalar h_con_polity= 7; 
scalar h_majpow2=0;  
scalar h_gencid=0;
scalar h_war=0; 
scalar h_ssafrica=0;
scalar h_spellmili=9.207655;
scalar h_spellmili2= 172.6125;
scalar h_spellmili3= 4447.729;
scalar h_constant=1;

    generate x_betahat0 = b1*(`a')
                            + b2*h_SDIAD
                            + b3*h_SDIAD*(`a')
                            + b4*h_ethltie
                            + b5*h_ethltie*(`a')
                            + b6*h_lratio
                            + b7*h_ally
                            + b8*h_lndistance
                            + b9*h_colhist
                            + b10*h_Coldwar 
                            + b11*h_premilint
                            + b12*h_spellmili
                            + b13*h_spellmili2
                            + b14*h_spellmili3
                            + b15*h_constant;                            
                           
        generate x_betahat1 = b1*(`a')
                            + b2*(h_SDIAD +1)
                            + b3*(h_SDIAD +1)*(`a')
                            + b4*h_ethltie
                            + b5*h_ethltie*(`a')
                            + b6*h_lratio
                            + b7*h_ally
                            + b8*h_lndistance
                            + b9*h_colhist
                            + b10*h_Coldwar 
                            + b11*h_premilint
                            + b12*h_spellmili
                            + b13*h_spellmili2
                            + b14*h_spellmili3
                            + b15*h_constant; 
                           
                                              
    gen prob0=normal(x_betahat0);
    gen prob1=normal(x_betahat1);
    gen diff = prob1 - prob0;
    
    egen probhat0=mean(prob0);
    egen probhat1=mean(prob1);
    egen diffhat= mean(diff);
    
    _pctile prob0, p(2.5,97.5) ;
    scalar lo0 = r(r1);
    scalar hi0 = r(r2);  
    
    _pctile prob1, p(2.5,97.5);
    scalar lo1= r(r1);
    scalar hi1= r(r2);  
    
    _pctile diff, p(2.5,97.5);
    scalar diff_lo= r(r1);
    scalar diff_hi= r(r2);  

    scalar diff_hat=diffhat ;
 
 
post mypost (diff_hat) (diff_lo) (diff_hi)  ;    
   
    drop x_betahat0 x_betahat1 prob0 prob1  diff  probhat0 probhat1 diffhat ;

    local a=`a'+ 1 ;
    display "." _c;
    } ;

display "";

postclose mypost;


use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", clear;

gen index= _n-1;
gen MV= index;

graph twoway line diff_hat MV, clwidth(medium) clcolor(blue) clcolor(black)
        ||   line diff_lo  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line diff_hi  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            
            xlabel(0 5 10 15 20 )
            yscale(noline)
            xscale(noline)
            yline(0)
            legend(pos(1) col(1) label(1 "Effect of lootable diamond") 
                   label(2 "95% confidence interval") 
                  order(1 2) region(lstyle(none)))
            
            xtitle(Polity Score, size(4)  )
            ytitle("Effct of lootable diamond", size(4))
            xsca(titlegap(2))
            ysca(titlegap(2))
            scheme(s2mono) graphregion(fcolor(white))
            name(Plootable,replace);



*     ****************************************************************  *;
*                 END                                                   *;
*     ****************************************************************  *; 






 
* *********************************************************************** *;
* *********************************************************************** *;
* *********************************************************************** *;
* Lootable Resoruces                                                      *;
* *********************************************************************** *;
* *********************************************************************** *;
* *********************************************************************** *;
#delimit; 
 use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\FYP_data_May2010_v1.dta", clear ;

estsimp probit  mili_intervention  third_W
SDIAD inter3_4 ethltie inter2_20 lratio ally lndistance colhist Coldwar     
premilint third_polity spellmili spellmili2 spellmili3 ,sims(10000) robust cluster(id) nolog;



postutil clear;
postfile mypost diff_hat diff_lo diff_hi
    using "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", replace;
noisily display "start";


local a= 0;
while `a' <= 1 { ;
    

scalar h_lratio= -1.058528;
scalar h_ethltie=0; 
scalar h_gempCNTR=0;
scalar h_SDIAD=0; 
scalar h_drugs=0;
scalar h_ally= 0;
scalar h_third_polity=8;
scalar h_lndistance=8.297453 ;
scalar h_distance=4937.091;
scalar h_colhist=0; 
scalar h_lcap_2=-7.074035;
scalar h_premilint=0; 
scalar h_Coldwar=1; 
scalar h_con_polity= 7; 
scalar h_majpow2=0;  
scalar h_gencid=0;
scalar h_war=0; 
scalar h_ssafrica=0;
scalar h_spellmili=9.207655;
scalar h_spellmili2= 172.6125;
scalar h_spellmili3= 4447.729;
scalar h_constant=1;

    generate x_betahat0 = b1*(`a')
                            + b2*h_SDIAD
                            + b3*h_SDIAD*(`a')
                            + b4*h_ethltie
                            + b5*h_ethltie*(`a')
                            + b6*h_lratio
                            + b7*h_ally
                            + b8*h_lndistance
                            + b9*h_colhist
                            + b10*h_Coldwar 
                            + b11*h_premilint
                            + b12*h_third_polity
                            + b13*h_spellmili
                            + b14*h_spellmili2
                            + b15*h_spellmili3
                            + b16*h_constant;                            
                           
        generate x_betahat1 =  b1*(`a')
                            + b2*(h_SDIAD +1)
                            + b3*(h_SDIAD +1)*(`a')
                            + b4*h_ethltie
                            + b5*h_ethltie*(`a')
                            + b6*h_lratio
                            + b7*h_ally
                            + b8*h_lndistance
                            + b9*h_colhist
                            + b10*h_Coldwar 
                             + b11*h_premilint
                            + b12*h_third_polity
                            + b13*h_spellmili
                            + b14*h_spellmili2
                            + b15*h_spellmili3
                            + b16*h_constant;                            

                                              
    gen prob0=normal(x_betahat0);
    gen prob1=normal(x_betahat1);
    gen diff = prob1 - prob0;
    
    egen probhat0=mean(prob0);
    egen probhat1=mean(prob1);
    egen diffhat= mean(diff);
    
    _pctile prob0, p(2.5,97.5) ;
    scalar lo0 = r(r1);
    scalar hi0 = r(r2);  
    
    _pctile prob1, p(2.5,97.5);
    scalar lo1= r(r1);
    scalar hi1= r(r2);  
    
    _pctile diff, p(2.5,97.5);
    scalar diff_lo= r(r1);
    scalar diff_hi= r(r2);  

    scalar diff_hat=diffhat ;
 
 
post mypost (diff_hat) (diff_lo) (diff_hi)  ;    
   
    drop x_betahat0 x_betahat1 prob0 prob1  diff  probhat0 probhat1 diffhat ;

    local a=`a'+ .05 ;
    display "." _c;
    } ;

display "";

postclose mypost;


use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", clear;

gen index= _n-1;
gen MV= index/20;

graph twoway line diff_hat MV, clwidth(medium) clcolor(blue) clcolor(black)
        ||   line diff_lo  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line diff_hi  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            
            xlabel(0 .25 .5 .75 1)  
            yscale(noline)
            xscale(noline)
            yline(0)
            legend(pos(1) col(1) label(1 "Effect of lootable diamond") 
                   label(2 "95% confidence interval") 
                  order(1 2) region(lstyle(none)))
            
            xtitle(Winning Coalition Size, size(4)  )
            ytitle("Effct of lootable diamond", size(4))
            xsca(titlegap(2))
            ysca(titlegap(2))
            scheme(s2mono) graphregion(fcolor(white))
            name(Wlootable,replace);



*     ****************************************************************  *;
*                 END                                                   *;
*     ****************************************************************  *; 




* *********************************************************************** *;
* *********************************************************************** *;
* *********************************************************************** *;
* Nonlootable Resources Hypotheses                                        *;
* *********************************************************************** *;
* *********************************************************************** *;
* *********************************************************************** *;


* *********************************************************************** *;
* *********************************************************************** *;
* *********************************************************************** *;
* Primary Diamond                                                        *;
* *********************************************************************** *;
* *********************************************************************** *;
* *********************************************************************** *;
#delimit; 
 use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\FYP_data_May2010_v1.dta", clear ;


#delimit;
estsimp probit  mili_intervention  third_polity 
SDIAD inter3_3  PDIAD inter4_3    ethltie inter2_19 lratio ally lndistance colhist Coldwar     
premilint  spellmili spellmili2 spellmili3 ,sims(10000) robust cluster(id) nolog;


postutil clear;
postfile mypost diff_hat diff_lo diff_hi
    using "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", replace;
noisily display "start";


local a= 0;
while `a' <= 20 { ;
    

scalar h_lratio= -1.058528;
scalar h_ethltie=0; 
scalar h_SDIAD=0;
scalar h_PDIAD=0; 
scalar h_drugs=0;
scalar h_ally= 0;
scalar h_lndistance=8.297453 ;
scalar h_distance=4937.091;
scalar h_colhist=0; 
scalar h_premilint=0; 
scalar h_Coldwar=1; 
scalar h_ssafrica=0;
scalar h_spellmili=9.207655;
scalar h_spellmili2= 172.6125;
scalar h_spellmili3= 4447.729;
scalar h_constant=1;


    generate x_betahat0 = b1*(`a')
                            + b2*h_SDIAD
                            + b3*h_SDIAD*(`a')
                            + b4*h_PDIAD
                            + b5*h_PDIAD*(`a')
                            + b6*h_ethltie
                            + b7*h_ethltie*(`a')
                            + b8*h_lratio
                            + b9*h_ally
                            + b10*h_lndistance
                            + b11*h_colhist
                            + b12*h_Coldwar
                            + b13*h_premilint
                            + b14*h_spellmili
                            + b15*h_spellmili2
                            + b16*h_spellmili3
                            + b17*h_constant;                            
                           

     
    generate x_betahat1 =  b1*(`a')
                            + b2*h_SDIAD
                            + b3*h_SDIAD*(`a')
                            + b4*(h_PDIAD +1)
                            + b5*(h_PDIAD +1)*(`a')
                            + b6*h_ethltie
                            + b7*h_ethltie*(`a')
                            + b8*h_lratio
                            + b9*h_ally
                            + b10*h_lndistance
                            + b11*h_colhist
                            + b12*h_Coldwar
                            + b13*h_premilint
                            + b14*h_spellmili
                            + b15*h_spellmili2
                            + b16*h_spellmili3
                            + b17*h_constant;                            
                           

    gen prob0=normal(x_betahat0);
    gen prob1=normal(x_betahat1);
    gen diff = prob1 - prob0;
    
    egen probhat0=mean(prob0);
    egen probhat1=mean(prob1);
    egen diffhat= mean(diff);
    
    _pctile prob0, p(2.5,97.5) ;
    scalar lo0 = r(r1);
    scalar hi0 = r(r2);  
    
    _pctile prob1, p(2.5,97.5);
    scalar lo1= r(r1);
    scalar hi1= r(r2);  
    
    _pctile diff, p(2.5,97.5);
    scalar diff_lo= r(r1);
    scalar diff_hi= r(r2);  

    scalar diff_hat=diffhat ;
 
 
post mypost (diff_hat) (diff_lo) (diff_hi)  ;    
   
    drop x_betahat0 x_betahat1 prob0 prob1  diff  probhat0 probhat1 diffhat ;

    local a=`a'+ 1 ;
    display "." _c;
    } ;

display "";

postclose mypost;


#delimit;
use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", clear;

gen index= _n-1;
gen MV= index;

graph twoway line diff_hat MV, clwidth(medium) clcolor(blue) clcolor(black)
        ||   line diff_lo  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line diff_hi  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            
            xlabel(0 5 10 15 20)
            yscale(noline)
            xscale(noline)
            yline(0)
            title("a. Nonlootable diamond", pos(11))
            legend(pos(11) col(1) label(1 "Effect of Nonlootable diamond") 
                  label(2 "95% confidence interval") 
                  order(1 2) region(lstyle(none)))
            
            xtitle(Polity Score, size(4)  )
            ytitle("Effct of nonlootable diamond", size(4))
            xsca(titlegap(2))
            ysca(titlegap(2))
            scheme(s2mono) graphregion(fcolor(white))
            name(Pnonlootable,replace);



*     ****************************************************************  *;
*                 Figure can be saved in a variety of formats.          *;
*     ****************************************************************  *; 




* *********************************************************************** *;
* *********************************************************************** *;
* *********************************************************************** *;
* Oil and Gas                                                              *;
* *********************************************************************** *;
* *********************************************************************** *;
* *********************************************************************** *;
#delimit; 
 use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\FYP_data_May2010_v1.dta", clear ;


#delimit;
estsimp probit  mili_intervention  third_polity 
SDIAD inter3_3  HydrocarbonpCNTR inter4_13  ethltie inter2_19 lratio ally lndistance colhist Coldwar     
premilint  spellmili spellmili2 spellmili3, sims(10000) robust cluster(id) nolog;


postutil clear;
postfile mypost diff_hat diff_lo diff_hi
    using "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", replace;
noisily display "start";


local a= 0;
while `a' <= 20 { ;
    

scalar h_lratio= -1.058528;
scalar h_ethltie=0; 
scalar h_SDIAD=0;
scalar h_PDIAD=0;
scalar h_HydrocarbonpCNTR=0; 
scalar h_drugs=0;
scalar h_ally= 0;
scalar h_lndistance=8.297453 ;
scalar h_distance=4937.091;
scalar h_colhist=0; 
scalar h_premilint=0; 
scalar h_Coldwar=1; 
scalar h_spellmili=9.207655;
scalar h_spellmili2= 172.6125;
scalar h_spellmili3= 4447.729;
scalar h_constant=1;


    generate x_betahat0 = b1*(`a')
                            + b2*h_SDIAD
                            + b3*h_SDIAD*(`a')
                            + b4*h_HydrocarbonpCNTR
                            + b5*h_HydrocarbonpCNTR*(`a')
                            + b6*h_ethltie
                            + b7*h_ethltie*(`a')
                            + b8*h_lratio                 
                            + b9*h_ally
                            + b10*h_lndistance
                            + b11*h_colhist
                            + b12*h_Coldwar
                            + b13*h_premilint
                            + b14*h_spellmili
                            + b15*h_spellmili2
                            + b16*h_spellmili3
                            + b17*h_constant;                            
                           

     
    generate x_betahat1 =  b1*(`a')
                            + b2*h_SDIAD
                            + b3*h_SDIAD*(`a')
                            + b4*(h_HydrocarbonpCNTR +1)
                            + b5*(h_HydrocarbonpCNTR +1)*(`a')
                            + b6*h_ethltie
                            + b7*h_ethltie*(`a')
                            + b8*h_lratio                 
                            + b9*h_ally
                            + b10*h_lndistance
                            + b11*h_colhist
                             + b12*h_Coldwar
                            + b13*h_premilint
                            + b14*h_spellmili
                            + b15*h_spellmili2
                            + b16*h_spellmili3
                            + b17*h_constant;                            
                           

                           

                                             
    gen prob0=normal(x_betahat0);
    gen prob1=normal(x_betahat1);
    gen diff = prob1 - prob0;
    
    egen probhat0=mean(prob0);
    egen probhat1=mean(prob1);
    egen diffhat= mean(diff);
    
    _pctile prob0, p(2.5,97.5) ;
    scalar lo0 = r(r1);
    scalar hi0 = r(r2);  
    
    _pctile prob1, p(2.5,97.5);
    scalar lo1= r(r1);
    scalar hi1= r(r2);  
    
    _pctile diff, p(2.5,97.5);
    scalar diff_lo= r(r1);
    scalar diff_hi= r(r2);  

    scalar diff_hat=diffhat ;
 
 
post mypost (diff_hat) (diff_lo) (diff_hi)  ;    
   
    drop x_betahat0 x_betahat1 prob0 prob1  diff  probhat0 probhat1 diffhat ;

    local a=`a'+ 1 ;
    display "." _c;
    } ;

display "";

postclose mypost;


#delimit;
use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", clear;

gen index= _n-1;
gen MV= index;

graph twoway line diff_hat MV, clwidth(medium) clcolor(blue) clcolor(black)
        ||   line diff_lo  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line diff_hi  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            
            xlabel(0 5 10 15 20)
            yscale(noline)
            xscale(noline)
            yline(0)
            title("c. Oil and Gas", pos(11))
            legend(pos(11) col(1) label(1 "Effect of Oil and Gas") 
                  label(2 "95% confidence interval") 
                  order(1 2) region(lstyle(none)))
            
            xtitle(Polity Score, size(4)  )
            ytitle("Effct of Oil and Gas", size(4))
            xsca(titlegap(2))
            ysca(titlegap(2))
            scheme(s2mono) graphregion(fcolor(white))
            name(Poil,replace);



*     ****************************************************************  *;
*                 Figure can be saved in a variety of formats.          *;
*     ****************************************************************  *; 
* *********************************************************************** *;


* *********************************************************************** *;
* *********************************************************************** *;
* *********************************************************************** *;
* Primary Diamond                                                        *;
* *********************************************************************** *;
* *********************************************************************** *;
* *********************************************************************** *;
#delimit; 
 use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\FYP_data_May2010_v1.dta", clear ;


#delimit;
estsimp probit  mili_intervention  third_W 
SDIAD inter3_4  PDIAD inter4_4    ethltie inter2_20 lratio ally lndistance colhist Coldwar     
premilint third_polity spellmili spellmili2 spellmili3,sims(10000) robust cluster(id) nolog;


postutil clear;
postfile mypost diff_hat diff_lo diff_hi
    using "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", replace;
noisily display "start";


local a= 0;
while `a' <= 1 { ;
    

scalar h_lratio= -1.058528;
scalar h_ethltie=0; 
scalar h_third_polity=8; 
scalar h_SDIAD=0;
scalar h_PDIAD=0; 
scalar h_drugs=0;
scalar h_ally= 0;
scalar h_lndistance=8.297453 ;
scalar h_distance=4937.091;
scalar h_colhist=0; 
scalar h_premilint=0; 
scalar h_Coldwar=1; 
scalar h_ssafrica=0;
scalar h_spellmili=9.207655;
scalar h_spellmili2= 172.6125;
scalar h_spellmili3= 4447.729;
scalar h_constant=1;


    generate x_betahat0 = b1*(`a')
                            + b2*h_SDIAD
                            + b3*h_SDIAD*(`a')
                            + b4*h_PDIAD
                            + b5*h_PDIAD*(`a')
                            + b6*h_ethltie
                            + b7*h_ethltie*(`a')
                            + b8*h_lratio
                            + b9*h_ally
                            + b10*h_lndistance
                            + b11*h_colhist
                            + b12*h_Coldwar
                            + b13*h_premilint
                            + b14*h_third_polity
                            + b15*h_spellmili
                            + b16*h_spellmili2
                            + b17*h_spellmili3
                            + b18*h_constant;                            
                           

     
    generate x_betahat1 =  b1*(`a')
                            + b2*h_SDIAD
                            + b3*h_SDIAD*(`a')
                            + b4*(h_PDIAD +1)
                            + b5*(h_PDIAD +1)*(`a')
                            + b6*h_ethltie
                            + b7*h_ethltie*(`a')
                            + b8*h_lratio
                            + b9*h_ally
                            + b10*h_lndistance
                            + b11*h_colhist
                              + b12*h_Coldwar
                            + b13*h_premilint
                            + b14*h_third_polity
                            + b15*h_spellmili
                            + b16*h_spellmili2
                            + b17*h_spellmili3
                            + b18*h_constant;                            
                           

                                             
    gen prob0=normal(x_betahat0);
    gen prob1=normal(x_betahat1);
    gen diff = prob1 - prob0;
    
    egen probhat0=mean(prob0);
    egen probhat1=mean(prob1);
    egen diffhat= mean(diff);
    
    _pctile prob0, p(2.5,97.5) ;
    scalar lo0 = r(r1);
    scalar hi0 = r(r2);  
    
    _pctile prob1, p(2.5,97.5);
    scalar lo1= r(r1);
    scalar hi1= r(r2);  
    
    _pctile diff, p(2.5,97.5);
    scalar diff_lo= r(r1);
    scalar diff_hi= r(r2);  

    scalar diff_hat=diffhat ;
 
 
post mypost (diff_hat) (diff_lo) (diff_hi)  ;    
   
    drop x_betahat0 x_betahat1 prob0 prob1  diff  probhat0 probhat1 diffhat ;

    local a=`a'+ .05 ;
    display "." _c;
    } ;

display "";

postclose mypost;


#delimit;
use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", clear;

gen index= _n-1;
gen MV= index/20;

graph twoway line diff_hat MV, clwidth(medium) clcolor(blue) clcolor(black)
        ||   line diff_lo  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line diff_hi  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            
            xlabel(0 .25 .5 .75 1)
            yscale(noline)
            xscale(noline)
            yline(0)
            title("b. Nonlootable diamond", pos(11))
            legend(pos(11) col(1) label(1 "Effect of Nonlootable diamond") 
                  label(2 "95% confidence interval") 
                  order(1 2) region(lstyle(none)))
            
            xtitle(Winning Coalition Size, size(4)  )
            ytitle("Effct of nonlootable diamond", size(4))
            xsca(titlegap(2))
            ysca(titlegap(2))
            scheme(s2mono) graphregion(fcolor(white))
            name(Wnonlootable,replace);



*     ****************************************************************  *;
*                 Figure can be saved in a variety of formats.          *;
*     ****************************************************************  *; 




* *********************************************************************** *;
* *********************************************************************** *;
* *********************************************************************** *;
* Oil and Gas                                                              *;
* *********************************************************************** *;
* *********************************************************************** *;
* *********************************************************************** *;
#delimit; 
 use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\FYP_data_May2010_v1.dta", clear ;


#delimit;
estsimp probit  mili_intervention  third_W
SDIAD inter3_4  HydrocarbonpCNTR inter4_14  ethltie inter2_20 lratio ally lndistance colhist Coldwar     
premilint  third_polity spellmili spellmili2 spellmili3, sims(10000) robust cluster(id) nolog;



postutil clear;
postfile mypost diff_hat diff_lo diff_hi
    using "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", replace;
noisily display "start";


local a= 0;
while `a' <= 1 { ;
    

scalar h_lratio= -1.058528;
scalar h_ethltie=0; 
scalar h_third_polity=8;
scalar h_SDIAD=0;
scalar h_PDIAD=0;
scalar h_HydrocarbonpCNTR=0; 
scalar h_drugs=0;
scalar h_ally= 0;
scalar h_lndistance=8.297453 ;
scalar h_distance=4937.091;
scalar h_colhist=0; 
scalar h_premilint=0; 
scalar h_Coldwar=1; 
scalar h_spellmili=9.207655;
scalar h_spellmili2= 172.6125;
scalar h_spellmili3= 4447.729;
scalar h_constant=1;


    generate x_betahat0 = b1*(`a')
                            + b2*h_SDIAD
                            + b3*h_SDIAD*(`a')
                            + b4*h_HydrocarbonpCNTR
                            + b5*h_HydrocarbonpCNTR*(`a')
                            + b6*h_ethltie
                            + b7*h_ethltie*(`a')
                            + b8*h_lratio                 
                            + b9*h_ally
                            + b10*h_lndistance
                            + b11*h_colhist
                            + b12*h_Coldwar
                            + b13*h_premilint
                            + b14*h_third_polity
                            + b15*h_spellmili
                            + b16*h_spellmili2
                            + b17*h_spellmili3
                            + b18*h_constant;                            
                           

     
    generate x_betahat1 =  b1*(`a')
                            + b2*h_SDIAD
                            + b3*h_SDIAD*(`a')
                            + b4*(h_HydrocarbonpCNTR +1)
                            + b5*(h_HydrocarbonpCNTR +1)*(`a')
                            + b6*h_ethltie
                            + b7*h_ethltie*(`a')
                            + b8*h_lratio                 
                            + b9*h_ally
                            + b10*h_lndistance
                            + b11*h_colhist
                          + b12*h_Coldwar
                            + b13*h_premilint
                            + b14*h_third_polity
                            + b15*h_spellmili
                            + b16*h_spellmili2
                            + b17*h_spellmili3
                            + b18*h_constant;                            
                           

                                             
    gen prob0=normal(x_betahat0);
    gen prob1=normal(x_betahat1);
    gen diff = prob1 - prob0;
    
    egen probhat0=mean(prob0);
    egen probhat1=mean(prob1);
    egen diffhat= mean(diff);
    
    _pctile prob0, p(2.5,97.5) ;
    scalar lo0 = r(r1);
    scalar hi0 = r(r2);  
    
    _pctile prob1, p(2.5,97.5);
    scalar lo1= r(r1);
    scalar hi1= r(r2);  
    
    _pctile diff, p(2.5,97.5);
    scalar diff_lo= r(r1);
    scalar diff_hi= r(r2);  

    scalar diff_hat=diffhat ;
 
 
post mypost (diff_hat) (diff_lo) (diff_hi)  ;    
   
    drop x_betahat0 x_betahat1 prob0 prob1  diff  probhat0 probhat1 diffhat ;

    local a=`a'+ .05 ;
    display "." _c;
    } ;

display "";

postclose mypost;


#delimit;
use "C:\Users\Jun\Documents\First Year (2) empirical\FYP_summer09\sim.dta", clear;

gen index= _n-1;
gen MV= index/20;

graph twoway line diff_hat MV, clwidth(medium) clcolor(blue) clcolor(black)
        ||   line diff_lo  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line diff_hi  MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            
            xlabel(0 .25 .5 .75  1)
            yscale(noline)
            xscale(noline)
            yline(0)
            title("d. Oil and Gas", pos(11))
            legend(pos(11) col(1) label(1 "Effect of Oil and Gas") 
                  label(2 "95% confidence interval") 
                  order(1 2) region(lstyle(none)))
            
            xtitle(Winnng Coalition Size, size(4)  )
            ytitle("Effct of Oil and Gas", size(4))
            xsca(titlegap(2))
            ysca(titlegap(2))
            scheme(s2mono) graphregion(fcolor(white))
            name(Woil,replace);



*     ****************************************************************  *;
*                 Figure can be saved in a variety of formats.          *;






* ******************************************************************** *; 
* ******************************************************************** *;
* Combine Graphs                                                       *; 
* ******************************************************************** *;
* ******************************************************************** *;


#delimit;
graph combine Plootable Wlootable,  iscale(*.9) imargin(small) ysize(6) xsize(8) col(2) 
    name(fig5, replace) saving(fig5, replace);

#delimit;
graph combine Pnonlootable Wnonlootable Poil Woil , iscale(*.9) imargin(small) ysize(12) xsize(14) col(2) 
      name(fig6, replace) saving(fig6, replace);

